//
//  AddTopicViewController.m
//  7.13苏宁框架
//
//  Created by app01 on 15/7/25.
//  Copyright (c) 2015年 lovena. All rights reserved.
//

#import "AddTopicViewController.h"
#import "DSZPostViewController.h"
#import "TopicCellModel.h"
#import "Common.h"


@interface AddTopicViewController ()

-(void)refreshUI;
-(void)loadData;
@property(retain,nonatomic)NSArray *topicArray;

@end

@implementation AddTopicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"添加话题";
    
    [self loadData];
    
}


-(void)loadData{
    _topicArray = [NSArray array];
    _topicArray = [TopicCellModel modelArrayWithFilename:@"topicCollectionCell.plist"];
}

-(void)refreshUI{
    [self.tableView reloadData];
}


#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return _topicArray.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *ID = @"cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:ID];
    }
    
    TopicCellModel *model = _topicArray[indexPath.row];
    cell.textLabel.text = model.title;
    
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    
    TopicCellModel *model = _topicArray[indexPath.row];
    NSString *string = model.title;
    // 发出通知
    [[NSNotificationCenter defaultCenter] postNotificationName:@"topicChange" object:string];

    [self.navigationController popViewControllerAnimated:YES];
}


-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    return  @"热门话题";
}

@end
